﻿<!--***********************************************************************************

   Extended WPF Toolkit

   Copyright (C) 2007-2013 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license 

   For more features, controls, and fast professional support,
   pick up the Plus Edition at http://xceed.com/wpf_toolkit

   Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids

  **********************************************************************************-->

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:s="clr-namespace:System;assembly=mscorlib"
                    xmlns:local="clr-namespace:Xceed.Wpf.DataGrid"
                    xmlns:conv="clr-namespace:Xceed.Wpf.DataGrid.Converters"
                    xmlns:markup="clr-namespace:Xceed.Wpf.DataGrid.Markup"
                    xmlns:views="clr-namespace:Xceed.Wpf.DataGrid.Views">

   <ResourceDictionary.MergedDictionaries>

      <!-- Include the view independant, color-scheme independant, theme resources -->
      <markup:DataGridThemeResourceDictionary Source="Resources/Aero2.NormalColor.Resources.xaml" />

      <!-- Include the view dependant, color-scheme independant, theme graphics -->
      <markup:DataGridThemeResourceDictionary Source="Resources/TableView.Aero2.NormalColor.Graphics.xaml" />

      <!-- Include the standard grid element templates -->
      <markup:DataGridThemeResourceDictionary Source="../Common/TableflowView.GridElementTemplates.xaml" />

      <!-- Control Styles used in the Grid Control -->
      <!-- TODO : for now do not use Aero2.NormalColor.Controls.xaml (see case 153892)  -->
      <!--<markup:DataGridThemeResourceDictionary Source="Resources/Aero2.NormalColor.Controls.xaml" />-->

   </ResourceDictionary.MergedDictionaries>

   <SolidColorBrush x:Key="warningBackgroundBrush"
                    Color="#FFC400" />

   <SolidColorBrush x:Key="warningForegroundBrush"
                    Color="Black" />

   <!-- ****************************************** -->
   <!-- Windows8 Font                              -->
   <!-- ****************************************** -->

   <FontFamily x:Key="defaultFontFamily">Segoe UI</FontFamily>
   <s:Double x:Key="defaultFontSize">12</s:Double>

   <!-- ****************************************** -->
   <!--  Windows8 Color Scheme                     -->
   <!-- ****************************************** -->

   <!-- Default -->
   <SolidColorBrush x:Key="defaultBackgroundBrush"
                    Color="White" />
   <SolidColorBrush x:Key="defaultForegroundBrush"
                    Color="#FF151C55" />

   <!-- DataGridControl -->
   <SolidColorBrush x:Key="gridBorderBrush"
                    Color="#FF5284BC" />

   <!-- ColumnManagerCell -->
   <LinearGradientBrush x:Key="columnManagerCellBackgroundBrush"
                        StartPoint="0,0"
                        EndPoint="0,1">
      <GradientStop Color="#FFF0F0F0"
                    Offset="0.0" />
      <GradientStop Color="#FFE5E5E5"
                    Offset="1.0" />
   </LinearGradientBrush>
   <SolidColorBrush x:Key="columnManagerCellMouseOverBackgroundBrush"
                    Color="#FFBEE6FD" />
   <SolidColorBrush x:Key="columnManagerCellPressedBackgroundBrush"
                    Color="#FFC4E5F6" />

   <!-- DataRow -->
   <SolidColorBrush x:Key="rowBackgroundBrush"
                    Color="White" />
   <SolidColorBrush x:Key="rowAlternatingBackgroundBrush"
                    Color="#FFF7F7F7" />
   <!-- TODO : determine the alternate row background color -->
   <SolidColorBrush x:Key="rowSelectionBackgroundBrush"
                    Color="#FFCBE8F6" />
   <SolidColorBrush x:Key="rowMouseOverBackgroundBrush"
                    Color="#FFE5F3FB" />
   <SolidColorBrush x:Key="rowMouseOverSelectionBackgroundBrush"
                    Color="#FFD1E8FF" />
   <SolidColorBrush x:Key="rowInactiveSelectionBackgroundBrush"
                    Color="#FFF7F7F7" />

   <!-- DataRow Borders (if we implement this behavior) -->
   <!--<SolidColorBrush x:Key="rowSelectionBorderBrush" Color="#FF26A0DA" />-->
   <!--<SolidColorBrush x:Key="rowMouseOverBorderBrush" Color="#FF70C0E7" />-->
   <!--<SolidColorBrush x:Key="rowMouseOverSelectionBorderBrush" Color="#FF66A7E8" />-->
   <!--<SolidColorBrush x:Key="rowInactiveSelectionBorderBrush" Color="#FFDEDEDE" />-->

   <!-- Groups -->
   <SolidColorBrush x:Key="groupByControlBackgroundBrush"
                    Color="Gray" />
   <SolidColorBrush x:Key="groupLevelIndicatorBackgroundBrush"
                    Color="#FFDFE7F2" />
   <LinearGradientBrush x:Key="groupHeaderBackgroundBrush"
                        StartPoint="0,0"
                        EndPoint="0,1">
      <GradientStop Color="#FFE9F1FC"
                    Offset="0.0" />
      <GradientStop Color="#FFDFE7F2"
                    Offset="1.0" />
   </LinearGradientBrush>

   <!-- =================================================================== -->
   <!-- Templates specific to this View/Theme/ColorScheme                   -->
   <!-- =================================================================== -->

   <!--**************************
    * TEMPLATE: GroupNavigationControl
    ************************** -->
   <ControlTemplate x:Key="tableflowViewGroupNavigationControlTemplate"
                    TargetType="{x:Type local:GroupNavigationControl}">

      <Grid>
         <Border x:Name="outlineBorder"
                 Background="Transparent"
                 BorderBrush="{StaticResource defaultForegroundBrush}"
                 BorderThickness="1"
                 CornerRadius="1"
                 Opacity="0" />

         <Grid>
            <Grid.ColumnDefinitions>
               <!-- Button part -->
               <ColumnDefinition Width="*" />

               <!-- Seperator part -->
               <ColumnDefinition Width="Auto" />

               <!-- Toggle button part -->
               <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Button x:Name="PART_Button"
                    Command="local:GroupNavigationButton.NavigateToGroup"
                    CommandParameter="{TemplateBinding Group}"
                    Content="{TemplateBinding Group}"
                    ContentTemplate="{TemplateBinding MainItemTemplate}"
                    ContentTemplateSelector="{TemplateBinding MainItemTemplateSelector}"
                    Foreground="{TemplateBinding Foreground}"
                    Focusable="False"
                    Grid.Column="0">
               <Button.Template>
                  <ControlTemplate TargetType="{x:Type Button}">
                     <Border Background="Transparent">
                        <ContentPresenter Margin="4,2,4,2" />
                     </Border>
                  </ControlTemplate>
               </Button.Template>
            </Button>

            <Border x:Name="seperator"
                    Grid.Column="1"
                    BorderThickness="0,0,1,0"
                    BorderBrush="{StaticResource defaultForegroundBrush}"
                    Margin="0,4,0,4"
                    Visibility="Hidden" />

            <ToggleButton x:Name="PART_ToggleButton"
                          Focusable="False"
                          IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
                          Grid.Column="2"
                          Foreground="{TemplateBinding Foreground}">
               <ToggleButton.Template>
                  <ControlTemplate>
                     <Border x:Name="toggleButtonBackground"
                             CornerRadius="0,6,6,0"
                             Background="Transparent">
                        <Path x:Name="Arrow"
                              Fill="{TemplateBinding Foreground}"
                              Margin="7,1,7,1"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              Data="M 0 0 L 4 4 L 0 8 Z"
                              Opacity="0.3" />
                     </Border>

                     <ControlTemplate.Triggers>
                        <Trigger Property="ToggleButton.IsMouseOver"
                                 Value="True">
                           <Setter TargetName="Arrow"
                                   Property="Opacity"
                                   Value="1" />
                        </Trigger>
                        <Trigger Property="ToggleButton.IsChecked"
                                 Value="True">
                           <Setter TargetName="Arrow"
                                   Property="Opacity"
                                   Value="1" />
                           <Setter TargetName="Arrow"
                                   Property="Margin"
                                   Value="5,1,5,1" />
                           <Setter TargetName="Arrow"
                                   Property="Data"
                                   Value="M 0 0 L 4 4 L 8 0 Z" />
                        </Trigger>
                     </ControlTemplate.Triggers>
                  </ControlTemplate>
               </ToggleButton.Template>
            </ToggleButton>
         </Grid>

         <Popup x:Name="PART_Popup"
                Placement="Bottom"
                IsOpen="{TemplateBinding IsDropDownOpen}"
                AllowsTransparency="True"
                Focusable="False"
                PopupAnimation="Slide">
            <Grid SnapsToDevicePixels="True"
                  MinWidth="{TemplateBinding ActualWidth}"
                  MaxHeight="{TemplateBinding MaxDropDownHeight}">
               <Border Background="White"
                       BorderBrush="Black"
                       BorderThickness="1"
                       TextElement.Foreground="Black">
                  <ScrollViewer CanContentScroll="True"
                                HorizontalScrollBarVisibility="Hidden"
                                VerticalScrollBarVisibility="Auto">
                     <!--<ItemsPresenter />-->
                     <VirtualizingStackPanel IsItemsHost="True" />
                  </ScrollViewer>
               </Border>
            </Grid>
         </Popup>
      </Grid>

      <ControlTemplate.Triggers>
         <Trigger Property="IsMouseOver"
                  Value="True">
            <Setter TargetName="outlineBorder"
                    Property="Opacity"
                    Value="1" />
            <Setter TargetName="seperator"
                    Property="Visibility"
                    Value="Visible" />
         </Trigger>

         <Trigger Property="IsDropDownOpen"
                  Value="True">
            <Setter TargetName="outlineBorder"
                    Property="Opacity"
                    Value="1" />
            <Setter TargetName="seperator"
                    Property="Visibility"
                    Value="Visible" />
         </Trigger>
         <Trigger Property="IsEnabled"
                  Value="False">
            <Setter Property="Opacity"
                    TargetName="outlineBorder"
                    Value="0" />
         </Trigger>
      </ControlTemplate.Triggers>
   </ControlTemplate>

   <!--**************************
    * TEMPLATE: GroupNavigationButton
    ************************** -->
   <ControlTemplate x:Key="tableflowViewGroupNavigationButtonTemplate"
                    TargetType="{x:Type local:GroupNavigationButton}">
      <Grid>
         <Border x:Name="outerBorder"
                 BorderBrush="{StaticResource defaultForegroundBrush}"
                 BorderThickness="1"
                 CornerRadius="1"
                 Opacity="0" />

         <ContentPresenter Margin="4,2,4,2" />
      </Grid>
      <ControlTemplate.Triggers>
         <Trigger Property="IsMouseOver"
                  Value="True">
            <Setter Property="Opacity"
                    TargetName="outerBorder"
                    Value="1" />
         </Trigger>
         <Trigger Property="IsEnabled"
                  Value="False">
            <Setter Property="Opacity"
                    TargetName="outerBorder"
                    Value="0" />
         </Trigger>
      </ControlTemplate.Triggers>
   </ControlTemplate>

   <!--**************************
    * TEMPLATE: RowSelector 
    ************************** -->
   <ControlTemplate x:Key="tableflowViewRowSelectorTemplate"
                    TargetType="local:RowSelector">

      <!-- This Grid is used to position the resizer Thumb over the RowSelector -->
      <Grid>

         <Border Background="{TemplateBinding Background}"
                 BorderBrush="{TemplateBinding BorderBrush}"
                 BorderThickness="{TemplateBinding BorderThickness}">

            <!-- This Grid is used to layout the delimiter lines on top of the ContentPresenter -->
            <Grid>

               <!-- This Border is used to apply the Padding around the ContentPresenter.
                    We cannot use the ContentPresenter's Margin for this purpose because
                    the Margin is used to represent the Pressed state. -->
               <Border Padding="{TemplateBinding Padding}">

                  <ContentPresenter x:Name="contentPresenter"
                                    Content="{TemplateBinding Content}"
                                    ContentTemplate="{TemplateBinding ContentTemplate}"
                                    ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />

               </Border>

               <!-- Bottom Line -->
               <Rectangle Fill="{StaticResource defaultForegroundBrush}"
                          HorizontalAlignment="Stretch"
                          VerticalAlignment="Top"
                          Height="1"
                          Margin="2,0,2,0" />

               <!-- Top Line -->
               <Rectangle x:Name="bottomBorder"
                          Fill="LightGray"
                          HorizontalAlignment="Stretch"
                          VerticalAlignment="Bottom"
                          Height="1"
                          Margin="2,0,2,0" />
            </Grid>
         </Border>

         <!-- Thumb that is used to resize the Row. -->
         <Thumb x:Name="PART_RowResizerThumb"
                Style="{StaticResource invisibleThumbStyle}"
                VerticalAlignment="Bottom" />

      </Grid>

      <ControlTemplate.Triggers>

         <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(views:ViewBase.IsLastItem)}"
                      Value="True">

            <Setter TargetName="bottomBorder"
                    Property="Fill"
                    Value="LightGray" />

         </DataTrigger>

      </ControlTemplate.Triggers>

   </ControlTemplate>

   <!--**************************
    * TEMPLATE: ColumnManagerCell 
    ************************** -->
    <conv:SortingDirectionToBooleanConverter x:Key="SortingDirectionToBooleanConverter" />

    <ControlTemplate x:Key="tableflowViewColumnManagerCellTemplate"
                     TargetType="local:ColumnManagerCell">
        <!-- This Grid is used to position the resizer Thumb over the ColumnManagerCell -->
        <Grid>

            <Border x:Name="rootBorder"
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}">

                <Grid>

                    <Rectangle Fill="LightGray"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Stretch"
                               Width="1"
                               Margin="0,2,0,2" />

                    <Rectangle Fill="{StaticResource defaultForegroundBrush}"
                               HorizontalAlignment="Right"
                               VerticalAlignment="Stretch"
                               Width="1"
                               Margin="0,2,0,2" />

                    <DockPanel>
                        <Border x:Name="thumbToggleBackgroundBorder"
                                DockPanel.Dock="Right">

                            <Grid>

                                <Border x:Name="toggleDelimeterBorder"
                                        BorderBrush="{StaticResource defaultForegroundBrush}"
                                        BorderThickness="1,0,0,0"
                                        Margin="0,4,0,4"
                                        Background="Transparent"
                                        Visibility="Collapsed">

                                    <Border x:Name="toggleDelimeterBorder2"
                                            BorderBrush="LightGray"
                                            BorderThickness="1,0,0,0"
                                            Margin="0,0,0,0"
                                            Background="Transparent"
                                            Visibility="Collapsed">

                                    </Border>
                                </Border>

                                <Border x:Name="borderToggleBackground"
                                        Background="{TemplateBinding Background}"
                                        Margin="1,0,1,0" />

                                <ToggleButton x:Name="toggleButton"
                                              Focusable="False"
                                              VerticalAlignment="Stretch"
                                              Visibility="Collapsed"
                                              Margin="2,0,0,0"
                                              Opacity="0.5" />
                            </Grid>
                        </Border>

                        <Border Background="{TemplateBinding Background}">

                            <!-- This Grid is used to layout the delimiter lines on top of the ContentPresenter -->
                            <Grid>

                                <Border Padding="{TemplateBinding Padding}">

                                    <Grid x:Name="contentPanel"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>

                                        <!-- Same ContentPresenter as in the base Cell Template. -->
                                        <local:CellContentPresenter x:Name="PART_CellContentPresenter"
                                                                    Grid.Column="0" />

                                        <!-- ContentPresenter that is used to display the sort glyph.
                                                We explicitely set its Content property to Null to prevent the XAML parser
                                                from implicitely setting it to its TemplatedParent's Content. -->
                                        <ContentPresenter x:Name="sortGlyphPresenter"
                                                          Grid.Column="1"
                                                          Content="{x:Null}"
                                                          ContentTemplate="{x:Null}" />
                                    </Grid>
                                </Border>
                            </Grid>
                        </Border>
                    </DockPanel>
                </Grid>
            </Border>

            <!-- Thumb that is used to resize the Column. -->
            <Thumb x:Name="PART_ColumnResizerThumbLeft"
                   Style="{StaticResource invisibleThumbStyle}"
                   Width="6"
                   HorizontalAlignment="Left" />

            <!-- Thumb that is used to resize the Column. -->
            <Thumb x:Name="PART_ColumnResizerThumb"
                   Style="{StaticResource invisibleThumbStyle}"
                   Width="6"
                   HorizontalAlignment="Right" />

        </Grid>

        <ControlTemplate.Triggers>

            <!-- The following triggers allows the content to correctly align to the center when the mouse is over the ColumnManagerCell and the HorizontalContentAlignment is Center -->
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Value="Visible"
                               Binding="{Binding ElementName=toggleButton, Path=Visibility}" />
                    <Condition Value="Center"
                               Binding="{Binding RelativeSource={RelativeSource Self},
                        Path=HorizontalContentAlignment}" />
                </MultiDataTrigger.Conditions>

                <Setter TargetName="PART_CellContentPresenter"
                        Property="Margin"
                        Value="16,0,0,0" />
            </MultiDataTrigger>

            <!-- Trigger related to the filteringToggleButton-->
            <Trigger SourceName="toggleButton"
                     Property="IsMouseOver"
                     Value="True">

                <Setter TargetName="toggleButton"
                        Property="Opacity"
                        Value="1" />
            </Trigger>

            <Trigger Property="IsBeingDragged"
                     Value="True">

                <Setter TargetName="borderToggleBackground"
                        Property="Margin"
                        Value="0,0,1,0" />

            </Trigger>

            <Trigger Property="IsPressed"
                     Value="True">

                <!-- Change background color of cell when IsPressed -->
                <Setter TargetName="rootBorder"
                        Property="Background"
                        Value="{StaticResource columnManagerCellPressedBackgroundBrush}" />
            </Trigger>

            <!-- Change background color of cell when MouseOver -->
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver"
                               Value="True" />
                    <Condition Property="IsPressed"
                               Value="False" />
                </MultiTrigger.Conditions>
                <Setter TargetName="rootBorder"
                        Property="Background"
                        Value="{StaticResource columnManagerCellMouseOverBackgroundBrush}" />
            </MultiTrigger>

            <!-- The following 2 triggers allow the appropriate Sort Glyph to be displayed
              depending on the ParentColumn's SortDirection. -->

            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=ParentColumn.SortDirection}"
                         Value="Ascending">

                <Setter TargetName="sortGlyphPresenter"
                        Property="ContentPresenter.ContentTemplate"
                        Value="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).AscendingSortGlyph}" />

                <Setter TargetName="sortGlyphPresenter"
                        Property="Margin"
                        Value="6,0,0,0" />

            </DataTrigger>

            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=ParentColumn.SortDirection}"
                         Value="Descending">

                <Setter TargetName="sortGlyphPresenter"
                        Property="ContentPresenter.ContentTemplate"
                        Value="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).DescendingSortGlyph}" />

                <Setter TargetName="sortGlyphPresenter"
                        Property="Margin"
                        Value="6,0,0,0" />
            </DataTrigger>

            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=ParentColumn.HasFixedWidth}"
                               Value="True" />

                    <!-- Don't disable resizing if ColumnStretching can be disabled by an 
                    end-user resize. -->
                    <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).RemoveColumnStretchingOnResize}"
                               Value="False" />
                </MultiDataTrigger.Conditions>

                <Setter TargetName="PART_ColumnResizerThumb"
                        Property="IsEnabled"
                        Value="False" />
            </MultiDataTrigger>

            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=ParentColumn.PreviousVisibleColumn.HasFixedWidth}"
                               Value="True" />

                    <!-- Don't disable resizing if ColumnStretching can be disabled by an 
                    end-user resize. -->
                    <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).RemoveColumnStretchingOnResize}"
                               Value="False" />
                </MultiDataTrigger.Conditions>

                <Setter TargetName="PART_ColumnResizerThumbLeft"
                        Property="IsEnabled"
                        Value="False" />
            </MultiDataTrigger>

            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=ParentRow.AllowColumnResize}"
                         Value="False">
                <Setter TargetName="PART_ColumnResizerThumb"
                        Property="IsEnabled"
                        Value="False" />
                <Setter TargetName="PART_ColumnResizerThumbLeft"
                        Property="IsEnabled"
                        Value="False" />
            </DataTrigger>

            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=ParentColumn.Visible}"
                         Value="False">
                <Setter Property="Visibility"
                        Value="Collapsed" />
            </DataTrigger>

        </ControlTemplate.Triggers>

    </ControlTemplate>

    <!--**************************
    * TEMPLATE: GroupByItem
    ************************** -->
   <ControlTemplate x:Key="tableflowViewGroupByItemTemplate"
                    TargetType="local:GroupByItem">

      <Border x:Name="mainBorder"
              Background="{TemplateBinding Background}"
              BorderBrush="{TemplateBinding BorderBrush}"
              BorderThickness="{TemplateBinding BorderThickness}"
              Padding="{TemplateBinding Padding}">

         <!-- This StackPanel is used to layout the ContentPresenter and the Sort Glyph (when present). -->
         <StackPanel Orientation="Horizontal">

            <!-- Same ContentPresenter as in the base Cell Template. -->
            <ContentPresenter Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />

            <!-- ContentPresenter that is used to display the sort glyph.
                 We explicitely set its Content property to Null to prevent the XAML parser
                 from implicitely setting it to its TemplatedParent's Content. -->
            <ContentPresenter x:Name="sortGlyphPresenter"
                              Content="{x:Null}"
                              ContentTemplate="{x:Null}"
                              Margin="15,0,0,0"
                              TextBlock.Foreground="{StaticResource defaultForegroundBrush}" />

         </StackPanel>
      </Border>

      <ControlTemplate.Triggers>

         <!-- The following 2 triggers allow to display the appropriate Sort Glyph
              depending on the ParentColumn's SortDirection. -->
         <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=SortDirection}"
                      Value="Ascending">

            <Setter TargetName="sortGlyphPresenter"
                    Property="ContentPresenter.ContentTemplate"
                    Value="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).AscendingSortGlyph}" />

            <Setter TargetName="sortGlyphPresenter"
                    Property="Margin"
                    Value="6,0,0,0" />

         </DataTrigger>

         <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=SortDirection}"
                      Value="Descending">

            <Setter TargetName="sortGlyphPresenter"
                    Property="ContentPresenter.ContentTemplate"
                    Value="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).DescendingSortGlyph}" />

            <Setter TargetName="sortGlyphPresenter"
                    Property="Margin"
                    Value="6,0,0,0" />

         </DataTrigger>

      </ControlTemplate.Triggers>
   </ControlTemplate>

   <!--**************************
    * TEMPLATE: HierarchicalGroupByControlNode
    ************************** -->
   <ControlTemplate x:Key="tableflowViewHierarchicalGroupByControlNodeTemplate"
                    TargetType="local:HierarchicalGroupByControlNode">

      <StackPanel Orientation="Horizontal"
                  Background="{TemplateBinding Background}">

         <Border BorderBrush="{StaticResource defaultForegroundBrush}"
                 Background="#55FFFFFF"
                 BorderThickness="1"
                 VerticalAlignment="Top"
                 HorizontalAlignment="Center">

            <TextBlock x:Name="titleTextBlock"
                       Text="{TemplateBinding Title}"
                       Margin="3"
                       FontFamily="{StaticResource defaultFontFamily}"
                       FontSize="{StaticResource defaultFontSize}" />

         </Border>

         <ItemsPresenter Margin="0,0,0,0" />

      </StackPanel>

   </ControlTemplate>

   <!--**************************
    * TEMPLATE: HierarchicalGroupByItem
    ************************** -->
   <ControlTemplate x:Key="tableflowViewHierarchicalGroupByItemTemplate"
                    TargetType="local:HierarchicalGroupByItem">
      <Grid>
         <Border x:Name="mainBorder"
                 Background="{TemplateBinding Background}"
                 BorderBrush="{TemplateBinding BorderBrush}"
                 BorderThickness="{TemplateBinding BorderThickness}"
                 Padding="{TemplateBinding Padding}">

            <!-- This StackPanel is used to layout the ContentPresenter and the Sort Glyph (when present). -->
            <StackPanel Orientation="Horizontal">

               <!-- Same ContentPresenter as in the base Cell Template. -->
               <ContentPresenter Content="{TemplateBinding Content}"
                                 ContentTemplate="{TemplateBinding ContentTemplate}"
                                 ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                 HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                 VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />

               <!-- ContentPresenter that is used to display the sort glyph.
                 We explicitely set its Content property to Null to prevent the XAML parser
                 from implicitely setting it to its TemplatedParent's Content. -->
               <ContentPresenter x:Name="sortGlyphPresenter"
                                 Content="{x:Null}"
                                 ContentTemplate="{x:Null}"
                                 Margin="15,0,0,0"
                                 TextBlock.Foreground="{StaticResource defaultForegroundBrush}" />

            </StackPanel>
         </Border>
      </Grid>
      <ControlTemplate.Triggers>

         <!-- The following 2 triggers allow to display the appropriate Sort Glyph
              depending on the ParentColumn's SortDirection. -->
         <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=SortDirection}"
                      Value="Ascending">

            <Setter TargetName="sortGlyphPresenter"
                    Property="ContentPresenter.ContentTemplate"
                    Value="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).AscendingSortGlyph}" />

            <Setter TargetName="sortGlyphPresenter"
                    Property="Margin"
                    Value="6,0,0,0" />

         </DataTrigger>

         <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=SortDirection}"
                      Value="Descending">

            <Setter TargetName="sortGlyphPresenter"
                    Property="ContentPresenter.ContentTemplate"
                    Value="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).DescendingSortGlyph}" />

            <Setter TargetName="sortGlyphPresenter"
                    Property="Margin"
                    Value="6,0,0,0" />

         </DataTrigger>

      </ControlTemplate.Triggers>
   </ControlTemplate>

   <!--**************************
    * TEMPLATE: GroupHeaderControl (copied from Office2007Blue)
    ************************** -->
   <conv:IntAdditionConverter x:Key="groupHeaderControlGroupLevelConverter" />
   <ControlTemplate x:Key="tableflowViewGroupHeaderControlTemplate"
                    TargetType="local:GroupHeaderControl">

      <!-- Using this decorator will prevent the GroupHeaderControl of exceeding the width 
           defined by the grid's column. -->
      <views:PassiveLayoutDecorator Axis="Horizontal">
         <DockPanel>

            <!-- GroupLevelIndicatorPane is a placeholder for individual GroupLevelIndicator elements that are added
              whenever this GroupHeaderControl is part of a group. -->
            <local:HierarchicalGroupLevelIndicatorPane DockPanel.Dock="Left" />
            <local:GroupLevelIndicatorPane DockPanel.Dock="Left"
                                           Indented="False"
                                           local:GroupLevelIndicatorPane.GroupLevel="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(local:GroupLevelIndicatorPane.GroupLevel), Converter={StaticResource groupHeaderControlGroupLevelConverter}, ConverterParameter=-1}" />
            <!-- Main Border for the GroupHeaderControl. It is Focusable to make the InputBindings work. -->
            <Border x:Name="mainBorder"
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    Padding="{TemplateBinding Padding}"
                    Focusable="True"
                    FocusVisualStyle="{TemplateBinding FocusVisualStyle}">

               <!-- Define all the standard InputBindings for a GroupHeaderControl. -->
               <Border.InputBindings>
                  <KeyBinding Command="{x:Static local:DataGridCommands.ToggleGroupExpansion}"
                              Key="Space" />

                  <KeyBinding Command="{x:Static local:DataGridCommands.ExpandGroup}"
                              Key="Right" />

                  <KeyBinding Command="{x:Static local:DataGridCommands.ExpandGroup}"
                              Key="Add" />

                  <KeyBinding Command="{x:Static local:DataGridCommands.CollapseGroup}"
                              Key="Left" />

                  <KeyBinding Command="{x:Static local:DataGridCommands.CollapseGroup}"
                              Key="Subtract" />

                  <MouseBinding Command="{x:Static local:DataGridCommands.ToggleGroupExpansion}"
                                MouseAction="LeftDoubleClick" />

               </Border.InputBindings>

               <DockPanel>

                  <!-- ToggleButton that is used to expand/collapse the group. -->
                  <ToggleButton DockPanel.Dock="Left"
                                OverridesDefaultStyle="True"
                                Template="{StaticResource groupExpanderToggleButtonTemplate}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                Focusable="False"
                                IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Group.IsExpanded}" />

                  <!-- ContentPresenter in charge of displaying this GroupHeaderControl's Content, which is a Group by default. -->
                  <ContentPresenter DockPanel.Dock="Left"
                                    Margin="3,0,0,0"
                                    Content="{TemplateBinding Content}"
                                    ContentTemplate="{TemplateBinding ContentTemplate}"
                                    ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />

                  <!-- Line that is traced across the GroupHeader, following the content -->
                  <Rectangle Fill="{StaticResource defaultForegroundBrush}"
                             VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                             HorizontalAlignment="Stretch"
                             Height="1"
                             Margin="7,0,0,0" />
               </DockPanel>
            </Border>
         </DockPanel>
      </views:PassiveLayoutDecorator>

      <ControlTemplate.Triggers>
         <Trigger Property="local:DataGridControl.NavigationBehavior"
                  Value="None">
            <Setter TargetName="mainBorder"
                    Property="Focusable"
                    Value="False" />
         </Trigger>
      </ControlTemplate.Triggers>
   </ControlTemplate>

   <!--**************************
    * TEMPLATE: GroupHeaderControl (When top level sticky)
    ************************** -->
   <ControlTemplate x:Key="tableflowViewGroupHeaderTopLevelStickyControlTemplate"
                    TargetType="local:GroupHeaderControl">

      <!-- Using this decorator will prevent the GroupHeaderControl of exceeding the width 
           defined by the grid's column. -->
      <views:PassiveLayoutDecorator Axis="Horizontal">
         <!-- This DockPanel is used to layout the GroupLevelIndicatorPane placeholder and the GroupHeaderControl Content. -->
         <DockPanel>

            <!-- GroupLevelIndicatorPane is a placeholder for individual GroupLevelIndicator elements that are added
              whenever this GroupHeaderControl is part of a group. -->
            <local:HierarchicalGroupLevelIndicatorPane DockPanel.Dock="Left" />
            <local:GroupLevelIndicatorPane DockPanel.Dock="Left"
                                           Indented="False"
                                           local:GroupLevelIndicatorPane.GroupLevel="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(local:GroupLevelIndicatorPane.GroupLevel), Converter={StaticResource groupHeaderControlGroupLevelConverter}, ConverterParameter=-1}" />

            <Grid>
               <Border Background="{StaticResource groupHeaderBackgroundBrush}" />

               <!-- Main Border for the GroupHeaderControl. It is Focusable to make the InputBindings work. -->
               <Border x:Name="mainBorder"
                       Background="Transparent"
                       BorderBrush="{TemplateBinding BorderBrush}"
                       BorderThickness="{TemplateBinding BorderThickness}"
                       Padding="{TemplateBinding Padding}"
                       Focusable="True"
                       FocusVisualStyle="{TemplateBinding FocusVisualStyle}">

                  <!-- Define all the standard InputBindings for a GroupHeaderControl. -->
                  <Border.InputBindings>
                     <KeyBinding Command="{x:Static local:DataGridCommands.ToggleGroupExpansion}"
                                 Key="Space" />

                     <KeyBinding Command="{x:Static local:DataGridCommands.ExpandGroup}"
                                 Key="Right" />

                     <KeyBinding Command="{x:Static local:DataGridCommands.ExpandGroup}"
                                 Key="Add" />

                     <KeyBinding Command="{x:Static local:DataGridCommands.CollapseGroup}"
                                 Key="Left" />

                     <KeyBinding Command="{x:Static local:DataGridCommands.CollapseGroup}"
                                 Key="Subtract" />

                     <MouseBinding Command="{x:Static local:DataGridCommands.ToggleGroupExpansion}"
                                   MouseAction="LeftDoubleClick" />

                  </Border.InputBindings>

                  <DockPanel>

                     <!-- ToggleButton that is used to expand/collapse the group. -->
                     <ToggleButton DockPanel.Dock="Left"
                                   OverridesDefaultStyle="True"
                                   Template="{StaticResource groupExpanderToggleButtonTemplate}"
                                   VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                   Focusable="False"
                                   IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Group.IsExpanded}" />

                     <!-- ContentPresenter in charge of displaying this GroupHeaderControl's Content, which is
                    a Group by default. -->
                     <ContentPresenter DockPanel.Dock="Left"
                                       Margin="3,0,0,0"
                                       Content="{TemplateBinding Content}"
                                       ContentTemplate="{TemplateBinding ContentTemplate}"
                                       ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                       VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                  </DockPanel>
               </Border>
            </Grid>
         </DockPanel>
      </views:PassiveLayoutDecorator>

      <ControlTemplate.Triggers>
         <Trigger Property="local:DataGridControl.NavigationBehavior"
                  Value="None">
            <Setter TargetName="mainBorder"
                    Property="Focusable"
                    Value="False" />
         </Trigger>
      </ControlTemplate.Triggers>

   </ControlTemplate>

   <!--**************************
    * TEMPLATE: ColumnManagerRow (copied from Common)
    ************************** -->
   <ControlTemplate x:Key="tableflowViewColumnManagerRowTemplate"
                    TargetType="local:ColumnManagerRow">

      <!-- A basic Row Template requires at least a Panel named "PART_CellsHost" to which the Row's cells will be added.
           This Panel is usually placed inside a Border who is responsible for painting the gridlines. -->

      <ControlTemplate.Resources>
         <conv:ThicknessConverter x:Key="thicknessConverter"
                                  InverseValue="True" />
      </ControlTemplate.Resources>

      <!-- This Grid is used to layout the GroupLevelIndicatorPane placeholder and the CellsHost panel. -->
      <Grid x:Name="rootGrid">
         <Grid.ColumnDefinitions>
            <!-- HierarchicalGroupLevelIndicatorPane -->
            <ColumnDefinition Width="Auto" />
            <!-- GroupLevelIndicatorPane -->
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />

            <!-- CellsHost panel -->
            <ColumnDefinition Width="*" />
         </Grid.ColumnDefinitions>

         <!-- The border responsible for the visual outline of the row (gridlines and background)
                       spans the GroupLevelIndicatorPane and CellsHost Panel. Those 2 elements are not children of
                       the Border because we don't want the border to be displayed in the GroupLevelIndicatorPane. -->
         <Border x:Name="rootBorder"
                 Grid.Column="1"
                 Grid.ColumnSpan="3"
                 views:TableView.CanScrollHorizontally="False"
                 Background="{TemplateBinding Background}"
                 BorderBrush="{TemplateBinding BorderBrush}"
                 BorderThickness="{TemplateBinding BorderThickness}"
                 Padding="{TemplateBinding Padding}" />

         <!-- GroupLevelIndicatorPane is a placeholder for individual GroupLevelIndicator elements that are added
                       whenever this Row is part of a group. -->
         <local:HierarchicalGroupLevelIndicatorPane views:TableView.CanScrollHorizontally="False"
                                                    Grid.Column="0"
                                                    Background="{TemplateBinding Background}" />
         <local:GroupLevelIndicatorPane x:Name="groupLevelIndicatorPane"
                                        views:TableView.CanScrollHorizontally="False"
                                        Grid.Column="1"
                                        Background="{TemplateBinding Background}" />

         <!-- ToggleButton that is used to expand/collapse the group. -->
         <Button x:Name="detailsToggle"
                 Template="{StaticResource detailsExpanderButtonTemplate}"
                 VerticalAlignment="Top"
                 Grid.Column="2"
                 Margin="2,4,2,0"
                 Command="{x:Static local:DataGridCommands.ToggleDetailExpansion}"
                 OverridesDefaultStyle="True"
                 Focusable="False"
                 Visibility="Collapsed"
                 views:TableView.CanScrollHorizontally="False" />

         <Decorator x:Name="indentationDecorator"
                    Grid.Column="3">

            <!-- The PART_CellsHost part designates the Panel to which this Row's Cells should be added.-->
            <views:FixedCellPanel x:Name="PART_CellsHost"
                                  ColumnStretchMinWidth="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).ColumnStretchMinWidth}"
                                  ColumnStretchMode="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).ColumnStretchMode}"
                                  FixedCellCount="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).FixedColumnCount, Mode=TwoWay}"
                                  FixedColumnDropMarkPen="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).FixedColumnDropMarkPen}"
                                  Margin="{TemplateBinding BorderThickness}" />
         </Decorator>

      </Grid>

      <ControlTemplate.Triggers>
         <!-- When there are details, display the Toggle button for the expansion, collapsing of the details -->
         <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).HasDetails}"
                          Value="True" />

               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).AllowDetailToggle}"
                          Value="True" />

            </MultiDataTrigger.Conditions>

            <Setter TargetName="detailsToggle"
                    Property="Visibility"
                    Value="Hidden" />

         </MultiDataTrigger>

      </ControlTemplate.Triggers>

   </ControlTemplate>

   <!--**************************
    * TEMPLATE: GroupLevelIndicatorPane (copied from common)
    ************************** -->
   <ControlTemplate x:Key="tableflowViewGroupLevelIndicatorPaneTemplate"
                    TargetType="local:GroupLevelIndicatorPane">
      <Grid>

         <Border x:Name="horizontalBorder"
                 Background="{TemplateBinding Background}"
                 BorderBrush="{TemplateBinding BorderBrush}"
                 BorderThickness="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).HorizontalGridLineThickness, Converter={StaticResource thicknessConverter}, ConverterParameter='Top, Bottom'}" />

         <Border x:Name="verticalBorder"
                 BorderBrush="{TemplateBinding BorderBrush}"
                 Padding="{TemplateBinding Padding}"
                 BorderThickness="0">
            <StackPanel x:Name="PART_GroupLevelIndicatorHost"
                        Orientation="Horizontal" />
         </Border>

      </Grid>
      <ControlTemplate.Triggers>
         <MultiTrigger>
            <MultiTrigger.Conditions>

               <Condition Property="CurrentIndicatorCount"
                          Value="0" />

               <Condition Property="IsLeaf"
                          Value="False" />
            </MultiTrigger.Conditions>

            <Setter TargetName="verticalBorder"
                    Property="BorderThickness"
                    Value="0" />
         </MultiTrigger>

         <Trigger Property="ShowVerticalBorder"
                  Value="False">
            <Setter TargetName="verticalBorder"
                    Property="BorderThickness"
                    Value="0" />
         </Trigger>
      </ControlTemplate.Triggers>
   </ControlTemplate>

   <!-- =================================================================== -->
   <!-- Styles required by some grid elements                               -->
   <!-- =================================================================== -->

   <!--**************************
    * STYLE: CellErrorStyle 
    ************************** -->
   <Style x:Key="cellErrorStyle"
          TargetType="local:Cell">

      <Setter Property="Background"
              Value="{StaticResource errorBackgroundBrush}" />

      <Setter Property="Foreground"
              Value="{StaticResource errorForegroundBrush}" />

      <Setter Property="ToolTip"
              Value="{Binding RelativeSource={RelativeSource Self},Path=ValidationError.ErrorContent}" />

      <Style.Triggers>
         <Trigger Property="IsValidationErrorRestrictive"
                  Value="True">
            <Setter Property="Background"
                    Value="{StaticResource errorBackgroundBrush}" />

         </Trigger>

         <Trigger Property="IsValidationErrorRestrictive"
                  Value="False">

            <Setter Property="Foreground"
                    Value="{StaticResource warningForegroundBrush}" />

            <Setter Property="Background"
                    Value="{StaticResource warningBackgroundBrush}" />

         </Trigger>
      </Style.Triggers>

   </Style>

   <!-- =================================================================== -->
   <!-- Keyed Styles of grid elements                                       -->
   <!-- =================================================================== -->

   <!--**************************
    * STYLE: DataGridControl 
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorGridControlStyle"
          TargetType="local:DataGridControl">

      <!-- TODO : for now do not use Aero2.NormalColor.Controls.xaml (see case 153892)  -->
      <!--<Style.Resources>
            <markup:DataGridThemeResourceDictionary Source="Resources/Aero2.NormalColor.Controls.xaml" />
        </Style.Resources>-->

      <Setter Property="BorderBrush"
              Value="{StaticResource gridBorderBrush}" />

      <Setter Property="BorderThickness"
              Value="1" />

      <Setter Property="Background"
              Value="{StaticResource defaultBackgroundBrush}" />

      <Setter Property="Foreground"
              Value="{StaticResource defaultForegroundBrush}" />

      <!-- This is required to display gridlines of uniform thickness -->
      <Setter Property="SnapsToDevicePixels"
              Value="True" />

      <Setter Property="CellErrorStyle"
              Value="{StaticResource cellErrorStyle}" />

      <Setter Property="Template"
              Value="{StaticResource tableflowViewDataGridControlTemplate}" />

   </Style>

   <!--**************************
    * STYLE: RowSelectorPane
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorRowSelectorPaneStyle"
          TargetType="local:RowSelectorPane">

      <!-- same background as the ColumnManagerCells -->
      <Setter Property="Background"
              Value="{StaticResource columnManagerCellBackgroundBrush}" />

      <Setter Property="TextElement.Foreground"
              Value="{StaticResource defaultForegroundBrush}" />

   </Style>

   <!--**************************
    * STYLE: RowSelector 
    ************************** -->
   <conv:TypeToBooleanConverter x:Key="rowTypeConverter" />
   <Style x:Key="tableflowViewAero2NormalColorRowSelectorStyle"
          TargetType="local:RowSelector">

      <!-- Set the RowSelector's background to Transparent to make it hit-testable
           while preserving the background drawn by the underlying RowSelectorPane. -->
      <Setter Property="Background"
              Value="Transparent" />

      <Setter Property="HorizontalContentAlignment"
              Value="Center" />

      <Setter Property="VerticalContentAlignment"
              Value="Top" />

      <Setter Property="Padding"
              Value="2" />

      <Setter Property="Template"
              Value="{StaticResource tableflowViewRowSelectorTemplate}" />

      <Style.Triggers>

         <!-- We have to use triggers on the type of the Row associated with this 
              RowSelector instead of assigning a value to RowSelector.RowSelectorStyle 
              on each row type. This is to avoid a custom RowSelector.RowSelectorStyle
              set by a client of the DataGridControl to completely override the 
              RowSelector style (DefaultStyleKey). -->

         <!-- When the Row is Current, display the current glyph in the RowSelector -->
         <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsCurrent}"
                          Value="True" />
            </MultiDataTrigger.Conditions>
            <Setter Property="ContentTemplate"
                    Value="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).CurrentItemGlyph}" />
         </MultiDataTrigger>

         <!-- When the Row is being edited, display the appropriate glyph in the RowSelector. -->
         <Trigger Property="IsBeingEdited"
                  Value="True">
            <Setter Property="ContentTemplate"
                    Value="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).EditingRowGlyph}" />

         </Trigger>

         <!-- When the Row has a validation error, display the appropriate glyph in the RowSelector. -->
         <Trigger Property="HasValidationError"
                  Value="True">
            <Setter Property="ContentTemplate"
                    Value="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).ValidationErrorGlyph}" />
         </Trigger>


         <!-- Use default Button States colors on the RowSelector -->
         <Trigger Property="IsMouseOver"
                  Value="True">
            <Setter Property="Background"
                    Value="{StaticResource columnManagerCellMouseOverBackgroundBrush}" />
         </Trigger>
         <Trigger Property="IsPressed"
                  Value="True">
            <Setter Property="Background"
                    Value="{StaticResource columnManagerCellPressedBackgroundBrush}" />
         </Trigger>

      </Style.Triggers>
   </Style>

   <!--**************************
    * STYLE: Row Style
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorRowStyle"
          TargetType="local:Row">

      <Setter Property="FontFamily"
              Value="{StaticResource defaultFontFamily}" />

      <Setter Property="FontSize"
              Value="{StaticResource defaultFontSize}" />

      <Setter Property="FocusVisualStyle"
              Value="{StaticResource tableflowViewRowFocusVisualStyle}" />

      <Setter Property="SelectionBackground"
              Value="{StaticResource rowSelectionBackgroundBrush}" />

      <Setter Property="SelectionForeground"
              Value="{StaticResource defaultForegroundBrush}" />

      <Setter Property="InactiveSelectionBackground"
              Value="{StaticResource rowInactiveSelectionBackgroundBrush}" />

      <Setter Property="InactiveSelectionForeground"
              Value="{StaticResource defaultForegroundBrush}" />

      <Setter Property="BorderThickness"
              Value="0" />

      <Setter Property="Template"
              Value="{StaticResource tableflowViewRowTemplate}" />

      <Setter Property="Background"
              Value="Transparent" />

      <Setter Property="Foreground"
              Value="{Binding RelativeSource={RelativeSource Self}, Path=ParentForeground}" />

      <Style.Triggers>

         <!-- Enabled/Disabled Odd datarow style alternation -->
         <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).IsAlternatingRowStyleEnabled}"
                          Value="True" />
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridVirtualizingPanel.ItemIndex), Converter={x:Static conv:IndexToOddConverter.Singleton}}"
                          Value="True" />
            </MultiDataTrigger.Conditions>
            <Setter Property="Background"
                    Value="{StaticResource rowAlternatingBackgroundBrush}" />
         </MultiDataTrigger>

      </Style.Triggers>
   </Style>

   <!--**************************
    * STYLE: DataRow 
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorDataRowStyle"
          TargetType="local:DataRow"
          BasedOn="{StaticResource tableflowViewAero2NormalColorRowStyle}">

      <Style.Triggers>
         <!-- MouseOver + NotSelected -->
         <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
               <Condition Binding="{Binding RelativeSource={RelativeSource Self},Path=(local:DataGridControl.DataGridContext).DataGridControl.SelectionUnit}"
                          Value="Row" />
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}"
                          Value="True" />
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}"
                          Value="False" />
            </MultiDataTrigger.Conditions>
            <Setter Property="Background"
                    Value="{StaticResource rowMouseOverBackgroundBrush}" />
         </MultiDataTrigger>

         <!-- MouseOver + Selected -->
         <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
               <Condition Binding="{Binding RelativeSource={RelativeSource Self},Path=(local:DataGridControl.DataGridContext).DataGridControl.SelectionUnit}"
                          Value="Row" />
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}"
                          Value="True" />
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}"
                          Value="True" />
            </MultiDataTrigger.Conditions>
            <Setter Property="SelectionBackground"
                    Value="{StaticResource rowMouseOverSelectionBackgroundBrush}" />
         </MultiDataTrigger>
      </Style.Triggers>

   </Style>

   <!--**************************
    * STYLE: ColumnManagerRow
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorColumnManagerRowStyle"
          TargetType="local:ColumnManagerRow"
          BasedOn="{StaticResource tableflowViewAero2NormalColorRowStyle}">

      <!-- Use a different background and foreground than the base Row style. -->
      <Setter Property="Background"
              Value="{StaticResource columnManagerCellBackgroundBrush}" />

      <Setter Property="Foreground"
              Value="{StaticResource defaultForegroundBrush}" />

      <Setter Property="BorderBrush"
              Value="{StaticResource defaultForegroundBrush}" />

      <Setter Property="BorderThickness"
              Value="0,1,0,1" />

      <Setter Property="local:RowSelector.Visible"
              Value="False" />

      <Setter Property="FontFamily"
              Value="{StaticResource defaultFontFamily}" />

      <Setter Property="FontSize"
              Value="{StaticResource defaultFontSize}" />

      <Setter Property="Padding"
              Value="12" />

      <Setter Property="Template"
              Value="{StaticResource tableflowViewColumnManagerRowTemplate}" />

      <Style.Triggers>

         <Trigger Property="local:GroupLevelIndicatorPane.GroupLevel"
                  Value="-1">
            <!-- We don't want to display the Group Margins for the ColumnManagerRow. -->
            <Setter Property="local:GroupLevelIndicatorPane.ShowIndicators"
                    Value="False" />
         </Trigger>

      </Style.Triggers>

   </Style>

   <!--**************************
    * STYLE: Cell Style
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorCellStyle"
          TargetType="local:Cell">

      <Setter Property="CurrentBackground"
              Value="{StaticResource defaultBackgroundBrush}" />

      <Setter Property="CurrentForeground"
              Value="{StaticResource defaultForegroundBrush}" />

      <Setter Property="SelectionBackground"
              Value="{StaticResource rowSelectionBackgroundBrush}" />

      <Setter Property="SelectionForeground"
              Value="{StaticResource defaultForegroundBrush}" />

      <Setter Property="InactiveSelectionBackground"
              Value="{StaticResource rowInactiveSelectionBackgroundBrush}" />

      <Setter Property="InactiveSelectionForeground"
              Value="{StaticResource defaultForegroundBrush}" />

      <!-- Set the Cell's background to Transparent to make it hit-testable
           while preserving the background drawn by the underlying Row. -->
      <Setter Property="Background"
              Value="Transparent" />

      <Setter Property="Foreground"
              Value="{Binding RelativeSource={RelativeSource Self}, Path=ParentForeground}" />

      <!-- In TableflowView, each Cell has the same width as its ParentColum's ActualWidth -->
      <Setter Property="Width"
              Value="{Binding RelativeSource={RelativeSource Self}, Path=ParentColumn.ActualWidth}" />

      <Setter Property="Padding"
              Value="{StaticResource cellPadding}" />

      <Setter Property="HorizontalContentAlignment"
              Value="{Binding RelativeSource={RelativeSource Self}, Path=ParentColumn.CellHorizontalContentAlignment, FallbackValue=Stretch}" />

      <Setter Property="VerticalContentAlignment"
              Value="{Binding RelativeSource={RelativeSource Self}, Path=ParentColumn.CellVerticalContentAlignment, FallbackValue=Stretch}" />

      <!-- The Cell is responsible for drawing the vertical gridlines. It draws only its right gridline, 
           assuming that the left gridline will have been drawn by its preceding cell -->

      <Setter Property="BorderThickness"
              Value="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).VerticalGridLineThickness, Converter={StaticResource thicknessConverter}, ConverterParameter='Right'}" />

      <Setter Property="BorderBrush"
              Value="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).VerticalGridLineBrush}" />

      <Setter Property="Template"
              Value="{StaticResource tableflowViewCellTemplate}" />
   </Style>

   <!--**************************
    * STYLE: DataCell
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorDataCellStyle"
          TargetType="local:DataCell"
          BasedOn="{StaticResource tableflowViewAero2NormalColorCellStyle}">

      <Style.Triggers>
         <!-- MouseOver + NotSelected -->
         <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
               <Condition Binding="{Binding RelativeSource={RelativeSource Self},Path=(local:DataGridControl.DataGridContext).DataGridControl.SelectionUnit}"
                          Value="Cell" />
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}"
                          Value="True" />
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}"
                          Value="False" />
            </MultiDataTrigger.Conditions>
            <Setter Property="Background"
                    Value="{StaticResource rowMouseOverBackgroundBrush}" />
         </MultiDataTrigger>

         <!-- MouseOver + Selected -->
         <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
               <Condition Binding="{Binding RelativeSource={RelativeSource Self},Path=(local:DataGridControl.DataGridContext).DataGridControl.SelectionUnit}"
                          Value="Cell" />
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}"
                          Value="True" />
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}"
                          Value="True" />
            </MultiDataTrigger.Conditions>
            <Setter Property="SelectionBackground"
                    Value="{StaticResource rowMouseOverSelectionBackgroundBrush}" />
         </MultiDataTrigger>
      </Style.Triggers>

   </Style>

   <!--**************************
    * STYLE: ColumnManagerCell
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorColumnManagerCellStyle"
          TargetType="local:ColumnManagerCell">

      <!-- Set the Cell's background to Transparent to make it hit-testable
           while preserving the background drawn by the underlying Row. -->
      <Setter Property="Background"
              Value="Transparent" />

      <!-- In TableflowView, each Cell has the same width as its ParentColum's ActualWidth -->
      <Setter Property="Width"
              Value="{Binding RelativeSource={RelativeSource Self},Path=ParentColumn.ActualWidth}" />

      <Setter Property="Padding"
              Value="{StaticResource cellPadding}" />

      <Setter Property="HorizontalContentAlignment"
              Value="{Binding RelativeSource={RelativeSource Self}, Path=ParentColumn.CellHorizontalContentAlignment, FallbackValue=Stretch}" />

      <Setter Property="VerticalContentAlignment"
              Value="{Binding RelativeSource={RelativeSource Self}, Path=ParentColumn.CellVerticalContentAlignment, FallbackValue=Stretch}" />

      <Setter Property="Template"
              Value="{StaticResource tableflowViewColumnManagerCellTemplate}" />

      <Style.Triggers>

         <Trigger Property="IsBeingDragged"
                  Value="True">
            <Setter Property="Background"
                    Value="{StaticResource columnManagerCellPressedBackgroundBrush}" />
         </Trigger>

      </Style.Triggers>
   </Style>

   <!--**************************
    * STYLE: GroupByControl
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorGroupByControlStyle"
          TargetType="local:GroupByControl">

      <!-- If we don't specify a MinHeight, the default "size-to-content" behavior will arrange 
           the control with a Height of 0, which makes it invisible and unusable.
           In a typical TableflowView, a height of at least 25 is appropriate for the GroupByControl. -->
      <Setter Property="MinHeight"
              Value="25" />

      <Setter Property="Background"
              Value="{StaticResource groupByControlBackgroundBrush}" />

      <Setter Property="Foreground"
              Value="{StaticResource defaultForegroundBrush}" />

      <Setter Property="FontFamily"
              Value="{StaticResource defaultFontFamily}" />

      <Setter Property="FontSize"
              Value="{StaticResource defaultFontSize}" />

      <Setter Property="Padding"
              Value="8" />

      <Setter Property="BorderBrush"
              Value="{StaticResource groupByControlBackgroundBrush}" />

      <Setter Property="BorderThickness"
              Value="1,1,1,0" />

      <Setter Property="local:RowSelector.Visible"
              Value="False" />

      <Setter Property="views:TableView.CanScrollHorizontally"
              Value="False" />

      <Setter Property="Template"
              Value="{StaticResource tableflowViewGroupByControlTemplate}" />

   </Style>

   <!--**************************
    * STYLE: GroupByItem
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorGroupByItemStyle"
          TargetType="local:GroupByItem">

      <Setter Property="Background"
              Value="{StaticResource columnManagerCellBackgroundBrush}" />

      <Setter Property="Foreground"
              Value="{StaticResource defaultForegroundBrush}" />

      <Setter Property="FontFamily"
              Value="{StaticResource defaultFontFamily}" />

      <Setter Property="FontSize"
              Value="{StaticResource defaultFontSize}" />

      <Setter Property="Padding"
              Value="{StaticResource cellPadding}" />

      <Setter Property="Template"
              Value="{StaticResource tableflowViewGroupByItemTemplate}" />

      <!-- Use default Button States colors on the GroupByItems -->
      <Style.Triggers>
         <Trigger Property="IsMouseOver"
                  Value="True">
            <Setter Property="Background"
                    Value="{StaticResource columnManagerCellMouseOverBackgroundBrush}" />
         </Trigger>
         <Trigger Property="IsPressed"
                  Value="True">
            <Setter Property="Background"
                    Value="{StaticResource columnManagerCellPressedBackgroundBrush}" />
         </Trigger>
      </Style.Triggers>

   </Style>

   <!--**************************
    * STYLE: GroupHeaderControl
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorGroupHeaderControlStyle"
          TargetType="local:GroupHeaderControl">

      <Setter Property="Background"
              Value="Transparent" />

      <Setter Property="Foreground"
              Value="{StaticResource defaultForegroundBrush}" />

      <Setter Property="FontFamily"
              Value="{StaticResource defaultFontFamily}" />

      <Setter Property="FontSize"
              Value="{StaticResource defaultFontSize}" />

      <Setter Property="views:TableView.CanScrollHorizontally"
              Value="False" />

      <Setter Property="Padding"
              Value="{StaticResource cellPadding}" />

      <Setter Property="VerticalContentAlignment"
              Value="Center" />

      <Setter Property="SelectionBackground"
              Value="{StaticResource rowSelectionBackgroundBrush}" />

      <Setter Property="SelectionForeground"
              Value="{StaticResource defaultForegroundBrush}" />

      <Setter Property="InactiveSelectionBackground"
              Value="{StaticResource rowInactiveSelectionBackgroundBrush}" />

      <Setter Property="InactiveSelectionForeground"
              Value="{StaticResource defaultForegroundBrush}" />

      <!-- The GroupHeaderControl itself must not be focusable. The main Border inside its Template will
           be made Focusable because it is holding the various InputBindings that make the
           GroupHeaderControl work. -->
      <Setter Property="Focusable"
              Value="False" />

      <Setter Property="Template"
              Value="{StaticResource tableflowViewGroupHeaderControlTemplate}" />

      <Style.Triggers>

         <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=Content.IsBottomLevel}"
                          Value="False" />
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=Content.Level}"
                          Value="0" />
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).AreGroupHeadersSticky}"
                          Value="True" />
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).AreGroupsFlattened}"
                          Value="True" />
            </MultiDataTrigger.Conditions>

            <Setter Property="Template"
                    Value="{StaticResource tableflowViewGroupHeaderTopLevelStickyControlTemplate}" />

         </MultiDataTrigger>

      </Style.Triggers>

   </Style>

   <!--**************************
    * STYLE: GroupLevelIndicator
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorGroupLevelIndicatorStyle"
          TargetType="local:GroupLevelIndicator">

      <Setter Property="Background"
              Value="White" />

      <Setter Property="Foreground"
              Value="{StaticResource defaultForegroundBrush}" />

      <Setter Property="BorderThickness"
              Value="0" />

      <Setter Property="Width"
              Value="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).GroupLevelIndicatorWidth}" />

      <Setter Property="Template"
              Value="{StaticResource tableflowViewGroupLevelIndicatorTemplate}" />

   </Style>

   <!--**************************
    * STYLE: DetailIndicator
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorDetailIndicatorStyle"
          TargetType="local:DetailIndicator">

      <Setter Property="Background"
              Value="{x:Null}" />

      <Setter Property="Width"
              Value="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).DetailIndicatorWidth}" />

      <Setter Property="Template"
              Value="{StaticResource tableflowViewDetailIndicatorTemplate}" />

   </Style>

   <!--**************************
    * STYLE: GroupLevelIndicatorPane
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorGroupLevelIndicatorPaneStyle"
          TargetType="local:GroupLevelIndicatorPane">

      <Setter Property="Template"
              Value="{StaticResource tableflowViewGroupLevelIndicatorPaneTemplate}" />

      <Setter Property="BorderBrush"
              Value="{StaticResource defaultForegroundBrush}" />

      <Style.Triggers>
         <MultiTrigger>
            <MultiTrigger.Conditions>
               <Condition Property="IsLeaf"
                          Value="False" />
               <Condition Property="views:ViewBase.IsLastItem"
                          Value="True" />
            </MultiTrigger.Conditions>

            <Setter Property="Margin"
                    Value="0,0,0,-5" />
         </MultiTrigger>

      </Style.Triggers>
   </Style>

   <!--**************************
    * STYLE: HierarchicalGroupLevelIndicatorPane
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorHierarchicalGroupLevelIndicatorPaneStyle"
          TargetType="local:HierarchicalGroupLevelIndicatorPane">

      <Setter Property="Template"
              Value="{StaticResource tableflowViewHierarchicalGroupLevelIndicatorPaneTemplate}" />

      <Setter Property="local:GroupLevelIndicatorPane.ShowIndicators"
              Value="True" />

      <Setter Property="local:GroupLevelIndicatorPane.ShowVerticalBorder"
              Value="True" />

      <Style.Triggers>
         <Trigger Property="local:GroupLevelIndicatorPane.GroupLevel"
                  Value="-1">

            <!-- Stop the propagation of the value set by the default style trigger of
                 the ColumnManagerRow -->
            <Setter Property="local:GroupLevelIndicatorPane.ShowIndicators"
                    Value="True" />

         </Trigger>
      </Style.Triggers>
   </Style>

   <!--**************************
    * STYLE: HierarchicalGroupByControlNode
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorHierarchicalGroupByControlNodeStyle"
          TargetType="local:HierarchicalGroupByControlNode">

      <Setter Property="StairHeight"
              Value="0" />

      <Setter Property="ConnectionLineOffset"
              Value="0" />

      <Setter Property="ConnectionLineAlignment"
              Value="CenterToCenter" />

      <Setter Property="Focusable"
              Value="False" />

      <Setter Property="Margin"
              Value="4" />

      <Setter Property="Template"
              Value="{StaticResource tableflowViewHierarchicalGroupByControlNodeTemplate}" />

   </Style>

   <!--**************************
    * STYLE: HierarchicalGroupByControl
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorHierarchicalGroupByControlStyle"
          TargetType="local:HierarchicalGroupByControl">

      <!-- If we don't specify a MinHeight, the default "size-to-content" behavior will arrange 
           the control with a Height of 0, which makes it invisible and unusable.
           In a typical TableflowView, a height of at least 25 is appropriate for the GroupByControl. -->
      <Setter Property="MinHeight"
              Value="25" />

      <Setter Property="Background"
              Value="{StaticResource groupByControlBackgroundBrush}" />

      <Setter Property="Foreground"
              Value="{StaticResource defaultForegroundBrush}" />

      <Setter Property="FontFamily"
              Value="{StaticResource defaultFontFamily}" />

      <Setter Property="FontSize"
              Value="{StaticResource defaultFontSize}" />

      <Setter Property="Padding"
              Value="8" />

      <Setter Property="BorderBrush"
              Value="{StaticResource groupByControlBackgroundBrush}" />

      <Setter Property="BorderThickness"
              Value="1,1,1,0" />

      <Setter Property="StairHeight"
              Value="0" />

      <Setter Property="ConnectionLineOffset"
              Value="0" />

      <Setter Property="ConnectionLineAlignment"
              Value="CenterToCenter" />

      <Setter Property="local:RowSelector.Visible"
              Value="False" />

      <Setter Property="views:TableView.CanScrollHorizontally"
              Value="False" />

      <Setter Property="Template"
              Value="{StaticResource tableflowViewCommonHierarchicalGroupByControlTemplate}" />

      <Style.Triggers>

         <!-- We use the old GroupByControl Template if there are no Details in the DataGridControl.ItemsSource -->
         <MultiDataTrigger>
            <MultiDataTrigger.Conditions>

               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).HasDetails}"
                          Value="False" />

               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).ParentDataGridContext, Converter={StaticResource nullToBooleanConverter}}"
                          Value="True" />

            </MultiDataTrigger.Conditions>

            <Setter Property="Template"
                    Value="{StaticResource tableflowViewCommonHierarchicalGroupByControlOldGroupByControlTemplate}" />

         </MultiDataTrigger>

      </Style.Triggers>

   </Style>

   <!--**************************
    * STYLE: HierarchicalGroupByItem
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorHierarchicalGroupByItemStyle"
          TargetType="local:HierarchicalGroupByItem">

      <Setter Property="Background"
              Value="{StaticResource columnManagerCellBackgroundBrush}" />

      <Setter Property="Foreground"
              Value="{StaticResource defaultForegroundBrush}" />

      <Setter Property="FontFamily"
              Value="{StaticResource defaultFontFamily}" />

      <Setter Property="FontSize"
              Value="{StaticResource defaultFontSize}" />

      <Setter Property="Padding"
              Value="{StaticResource cellPadding}" />

      <Setter Property="Margin"
              Value="4,0,4,0" />

      <Setter Property="Template"
              Value="{StaticResource tableflowViewHierarchicalGroupByItemTemplate}" />

      <!-- Use default Button States colors on the HierarchicalGroupByItems -->
      <Style.Triggers>
         <Trigger Property="IsMouseOver"
                  Value="True">
            <Setter Property="Background"
                    Value="{StaticResource columnManagerCellMouseOverBackgroundBrush}" />
         </Trigger>
         <Trigger Property="IsPressed"
                  Value="True">
            <Setter Property="Background"
                    Value="{StaticResource columnManagerCellPressedBackgroundBrush}" />
         </Trigger>
      </Style.Triggers>

   </Style>

   <!--**************************
    * STYLE: ScrollTip
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorScrollTipStyle"
          TargetType="local:ScrollTip">

      <Setter Property="Template"
              Value="{StaticResource scrollTipTemplate}" />

      <Setter Property="VerticalAlignment"
              Value="Center" />

      <Setter Property="HorizontalAlignment"
              Value="Right" />

      <Setter Property="Background"
              Value="{StaticResource groupHeaderBackgroundBrush}" />

      <Setter Property="Foreground"
              Value="{StaticResource defaultForegroundBrush}" />

      <Setter Property="BorderBrush"
              Value="{StaticResource defaultForegroundBrush}" />

   </Style>

   <!--**************************
    * STYLE: GroupNavigationControl
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorGroupNavigationControlStyle"
          TargetType="local:GroupNavigationControl">
      <Setter Property="Template"
              Value="{StaticResource tableflowViewGroupNavigationControlTemplate}" />
   </Style>

   <!--**************************
    * STYLE: GroupNavigationControlItem
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorGroupNavigationControlItemStyle"
          TargetType="{x:Type local:GroupNavigationControlItem}">

      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:GroupNavigationControlItem}">
               <Grid SnapsToDevicePixels="true">
                  <Border x:Name="Border"
                          Background="Transparent" />
                  <Border Margin="2">
                     <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                       VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                  </Border>
               </Grid>
               <ControlTemplate.Triggers>

                  <!-- Change IsSelected SelectedBackgroundBrush to set the selection color for the items -->
                  <Trigger Property="IsMouseOver"
                           Value="true">
                     <Setter Property="Background"
                             TargetName="Border"
                             Value="{StaticResource rowMouseOverSelectionBackgroundBrush}" />

                     <Setter Property="Foreground"
                             Value="Black" />
                  </Trigger>

                  <Trigger Property="IsEnabled"
                           Value="false">
                     <Setter Property="Foreground"
                             Value="Gray" />
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!--**************************
    * STYLE: GroupNavigationButton
    ************************** -->
   <Style x:Key="tableflowViewAero2NormalColorGroupNavigationButtonStyle"
          TargetType="local:GroupNavigationButton">
      <Setter Property="Template"
              Value="{StaticResource tableflowViewGroupNavigationButtonTemplate}" />
   </Style>

   <!-- =================================================================== -->
   <!-- Default values for the View                                         -->
   <!-- =================================================================== -->

   <Style x:Key="tableflowViewAero2NormalColorDefaultValues"
          TargetType="views:TableflowView">

      <Setter Property="HorizontalGridLineBrush"
              Value="{StaticResource gridLineBrush}" />

      <Setter Property="HorizontalGridLineThickness"
              Value="1" />

      <Setter Property="GroupLevelIndicatorWidth"
              Value="17" />

      <Setter Property="DetailIndicatorWidth"
              Value="34" />

      <Setter Property="ContainerHeight"
              Value="30" />

      <Setter Property="DefaultDropMarkPen"
              Value="{StaticResource dropMarkPen}" />

      <!-- Those glyphs are null by default on ViewBase, so every Theme should define
           and set their own custom glyphs. -->

      <Setter Property="AscendingSortGlyph"
              Value="{StaticResource ascendingSortGlyph}" />

      <Setter Property="DescendingSortGlyph"
              Value="{StaticResource descendingSortGlyph}" />

      <Setter Property="ExpandGroupGlyph"
              Value="{StaticResource expandGroupGlyph}" />

      <Setter Property="CollapseGroupGlyph"
              Value="{StaticResource collapseGroupGlyph}" />

      <Setter Property="CurrentItemGlyph"
              Value="{StaticResource currentItemGlyph}" />

      <Setter Property="EditingRowGlyph"
              Value="{StaticResource editingRowGlyph}" />

      <Setter Property="ValidationErrorGlyph"
              Value="{StaticResource validationErrorGlyph}" />

      <Setter Property="ConnectionStateLoadingGlyph"
              Value="{StaticResource connectionStateLoadingGlyph}" />

      <Setter Property="ConnectionStateCommittingGlyph"
              Value="{StaticResource connectionStateLoadingGlyph}" />

      <Setter Property="ConnectionStateErrorGlyph"
              Value="{StaticResource connectionStateErrorGlyph}" />

   </Style>

   <!-- =================================================================== -->
   <!-- DefaultStyleKey declarations                                        -->
   <!-- =================================================================== -->

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme}"
          TargetType="views:TableflowView"
          BasedOn="{StaticResource tableflowViewAero2NormalColorDefaultValues}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:DataGridControl}"
          TargetType="local:DataGridControl"
          BasedOn="{StaticResource tableflowViewAero2NormalColorGridControlStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:RowSelectorPane}"
          TargetType="local:RowSelectorPane"
          BasedOn="{StaticResource tableflowViewAero2NormalColorRowSelectorPaneStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:RowSelector}"
          TargetType="local:RowSelector"
          BasedOn="{StaticResource tableflowViewAero2NormalColorRowSelectorStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:Row}"
          TargetType="local:Row"
          BasedOn="{StaticResource tableflowViewAero2NormalColorRowStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:DataRow}"
          TargetType="local:DataRow"
          BasedOn="{StaticResource tableflowViewAero2NormalColorDataRowStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:ColumnManagerRow}"
          TargetType="local:ColumnManagerRow"
          BasedOn="{StaticResource tableflowViewAero2NormalColorColumnManagerRowStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:Cell}"
          TargetType="local:Cell"
          BasedOn="{StaticResource tableflowViewAero2NormalColorCellStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:DataCell}"
          TargetType="local:DataCell"
          BasedOn="{StaticResource tableflowViewAero2NormalColorDataCellStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:ColumnManagerCell}"
          TargetType="local:ColumnManagerCell"
          BasedOn="{StaticResource tableflowViewAero2NormalColorColumnManagerCellStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:GroupByControl}"
          TargetType="local:GroupByControl"
          BasedOn="{StaticResource tableflowViewAero2NormalColorGroupByControlStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:GroupByItem}"
          TargetType="local:GroupByItem"
          BasedOn="{StaticResource tableflowViewAero2NormalColorGroupByItemStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:GroupHeaderControl}"
          TargetType="local:GroupHeaderControl"
          BasedOn="{StaticResource tableflowViewAero2NormalColorGroupHeaderControlStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:GroupLevelIndicator}"
          TargetType="local:GroupLevelIndicator"
          BasedOn="{StaticResource tableflowViewAero2NormalColorGroupLevelIndicatorStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:DetailIndicator}"
          TargetType="local:DetailIndicator"
          BasedOn="{StaticResource tableflowViewAero2NormalColorDetailIndicatorStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:GroupLevelIndicatorPane}"
          TargetType="local:GroupLevelIndicatorPane"
          BasedOn="{StaticResource tableflowViewAero2NormalColorGroupLevelIndicatorPaneStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:HierarchicalGroupLevelIndicatorPane}"
          TargetType="local:HierarchicalGroupLevelIndicatorPane"
          BasedOn="{StaticResource tableflowViewAero2NormalColorHierarchicalGroupLevelIndicatorPaneStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:ScrollTip}"
          TargetType="local:ScrollTip"
          BasedOn="{StaticResource tableflowViewAero2NormalColorScrollTipStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:HierarchicalGroupByControlNode}"
          TargetType="local:HierarchicalGroupByControlNode"
          BasedOn="{StaticResource tableflowViewAero2NormalColorHierarchicalGroupByControlNodeStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:HierarchicalGroupByControl}"
          TargetType="local:HierarchicalGroupByControl"
          BasedOn="{StaticResource tableflowViewAero2NormalColorHierarchicalGroupByControlStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:HierarchicalGroupByItem}"
          TargetType="local:HierarchicalGroupByItem"
          BasedOn="{StaticResource tableflowViewAero2NormalColorHierarchicalGroupByItemStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:GroupNavigationButton}"
          TargetType="local:GroupNavigationButton"
          BasedOn="{StaticResource tableflowViewAero2NormalColorGroupNavigationButtonStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:GroupNavigationControl}"
          TargetType="local:GroupNavigationControl"
          BasedOn="{StaticResource tableflowViewAero2NormalColorGroupNavigationControlStyle}" />

   <Style x:Key="{markup:ThemeKey TargetViewType=views:TableflowView, ThemeType=views:Windows8Theme, TargetElementType=local:GroupNavigationControlItem}"
          TargetType="local:GroupNavigationControlItem"
          BasedOn="{StaticResource tableflowViewAero2NormalColorGroupNavigationControlItemStyle}" />

</ResourceDictionary>
